/*
 * @Date: 2021-09-08 15:12:43
 * @Author: Acckno1
 * @LastEditTime: 2021-09-08 15:30:44
 * @Description: 
 */
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <bitset>
#include <utility>
using namespace std;

#define mm(a, n) memset(a, n, sizeof a)
#define mk(a, b) make_pair(a, b)

const double eps = 1e-6;
const int INF = 0x3f3f3f3f;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef pair<double, double> PDD;
typedef pair<LL, LL> PLL;
typedef pair<int, LL> PIL;

inline void quickread() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

const int N = 5e4 + 10;

int n, k;
int cnt[N], nums[N];
int lst[15];

bool cmp(int a, int b) {
    if (cnt[a] != cnt[b]) 
        return cnt[a] > cnt[b];
    return a < b;
}

inline void solution() {
    scanf("%d%d", &n, &k);
    int m = 0;
    mm(lst, -1);
    for (int i = 0; i < n; i ++ )
        scanf("%d", nums[i]);

    // set维护当前列表里面有那些推荐商品
    unordered_set<int> st;
    for (int i = 0; i < n - 1; i ++ ) {
        cnt[nums[i]] ++ ;
        // 如果这个商品没有在推荐系统里面，添加进去；
        if (!st.count(nums[i])) 
            lst[k] = nums[i], st.insert(nums[i]);
        // 自定义排完序之后 lst[k] 需要被删除
        sort(lst, lst + n, cmp);
        if (lst[k] != -1) 
            st.erase(lst[k]);
        printf("%d:", nums[i + 1]);
        for (int i = 0; i < k && lst[i] != -1; i ++ )
            printf(" %d", lst[i]);
        printf("\n");
    }
}

int main() {
    freopen("input.txt", "r", stdin);
    quickread();
    solution();
    return 0;
}